<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <base th:href="@{/}">
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/static/css/common.css}">
</head>
<body>
<form lay-filter="scenicForm" class="layui-form model-form">
    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-block">
            <input name="name" type="text" class="layui-input" placeholder="请输入类别名称"
                   maxlength="20" lay-verify="required" required/>
        </div>
    </div>

    <div class="layui-form-item text-right">
        <button class="layui-btn layui-btn-primary" type="button" id="closeDialog">取消</button>
        <button class="layui-btn" lay-filter="articleFormSubmit" lay-submit>保存</button>
    </div>
</form>
</body>
<script type="text/javascript" th:src="@{/static/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/static/js/common.js}"></script>
<script type="text/javascript" th:src="@{/static/js/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/static/js/admin.js}"></script>
<script>

    layui.use(['form','laydate','layer','admin','util','upload'], function() {
        var form = layui.form,
            layer=layui.layer,
            admin=layui.admin,
            upload = layui.upload;

        form.on('submit(articleFormSubmit)', function (d) {
            layer.load(2);
            admin.req('type/add', d.field, function (res) {
                layer.closeAll('loading');
                layer.alert(res.msg, {icon: res.code == 200 ? 6 : 5},function () {
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                    //刷新页面
                    parent.location.replace(parent.location.href);
                });
            },'POST');
            return false;
        });

        $('#closeDialog').click(function () {
            var index = parent.layer.getFrameIndex(window.name);
            //关闭当前frame
            parent.layer.close(index);
        });


    });
</script>
</html>